<template>
	<div>
		<cl-crud @load="onLoad">
			<template #slot-delete="scope">
				<delBtn @del="crud.delete(scope.row)"></delBtn>
			</template>
		</cl-crud>
		<cl-form ref="cl-form"></cl-form>
	</div>
</template>

<script>
import delBtn from '@/components/common/del-btn';
export default {
	data() {
		return {
			crud: null
		};
	},
	components: {
		delBtn
	},
	methods: {
		onLoad({ ctx, app }) {
			this.crud = app;

			ctx.service(this.$service.platform.app)
				.permission({
					update: true,
					delete: true,
					add: true
				})
				.set('dict', {
					label: {
						add: '添加客服+'
					}
				})
				.set('table', {
					columns: [
						{
							label: '序号',
							type: 'index',
							align: 'center',
							width: 60
						},
						{
							label: '平台名称',
							prop: 'name',
							align: 'center'
						},
						// {
						// 	label: '客服类型',
						// 	prop: 'kftype',
						// 	align: 'center'
						// },
						// {
						// 	label: '客服图标',
						// 	prop: 'kficon',
						// 	align: 'center'
						// },
						{
							label: '平台key',
							prop: 'key',
							align: 'center'
						},
						{
							label: '客服昵称',
							prop: 'name',
							align: 'center'
						},
						{
							label: '更新时间',
							prop: 'updateTime',
							align: 'center'
						},
						{
							label: '创建时间',
							prop: 'createTime',
							align: 'center',
							sortable: 'custom',
							emptyText: '0'
						}
					],

					op: {
						layout: ['slot-delete'],
						visible: false
					}
				})
				.set('upsert', {
					props: {
						labelWidth: '100px'
					},
					items: []
				})
				.set('layout', [
					['refresh-btn', 'flex1', 'search-key'],
					['data-table'],
					['flex1', 'pagination']
				])
				.on('submit', async (isEdit, data) => {
					console.log(data);
				})
				.done();

			app.refresh();
		}
	}
};
</script>

<style lang="succ" scoped></style>
